#include <stdio.h>
#include <string.h>

char map[21][21];
char sign[21][21];

int kmovex[]={-1,-1,-1,0,0,1,1,1};
int kmovey[]={-1,0,1,-1,1,-1,0,1};
int rmovex[]={-1,1,0,0};
int rmovey[]={0,0,1,-1};
int bmovex[]={1,1,-1,-1};
int bmovey[]={1,-1,1,-1};
int nmovex[]={-2,-2,-1,-1, 1, 1, 2, 2};
int nmovey[]={-1, 1, 2,-2, 2,-2, 1,-1};

void setp(int x, int y)
{
	int tox,toy;
	tox=x+1;toy=y+1;
	if (map[tox][toy]==' ') sign[tox][toy]=1;
	tox=x+1;toy=y-1;
	if (map[tox][toy]==' ') sign[tox][toy]=1;
}
void setp2(int x, int y)
{
	int tox,toy;
	tox=x-1;toy=y-1;
	if (map[tox][toy]==' ') sign[tox][toy]=1;
	tox=x-1;toy=y+1;
	if (map[tox][toy]==' ') sign[tox][toy]=1;
}

void setn(int x, int y) //马
{
	int i,tox, toy;
	for (i=0;i<8;i++)
	{
		tox=x+nmovex[i];
		toy=y+nmovey[i];
		if (tox>0 && toy>0 && map[tox][toy]==' ')
			sign[tox][toy]=1;
	}
}

void setking(int x,int y) //国王
{
	int i;
	int tox,toy;
	for (i=0;i<8;i++)
	{
		tox=x+kmovex[i];
		toy=y+kmovey[i];
		if (tox>0 && toy>0 && tox<9 && toy<9 && map[tox][toy]==' ')
			sign[tox][toy]=1;
	}
}
void setr(int x,int y)  //车
{
	int tox,toy,i;
	for (i=0;i<4;i++)
	{
		tox=x+rmovex[i];
		toy=y+rmovey[i];
		while ( tox>0 && toy>0 && tox<9 && toy<9 && map[tox][toy]==' ' )
		{
			sign[tox][toy]=1;
			tox+=rmovex[i];
			toy+=rmovey[i];
		}
	}
}
void setb(int x,int y) //象
{
	int tox,toy,i;
	for (i=0;i<4;i++)
	{
		tox=x+bmovex[i];
		toy=y+bmovey[i];
		while (tox>0 && toy>0 && tox<9 && toy<9 && map[tox][toy]==' ' )
		{
			sign[tox][toy]=1;
			tox+=bmovex[i];
			toy+=bmovey[i];
		}
	}
}
void setq(int x, int y) //王后
{
	int tox,toy,i;
	for (i=0;i<4;i++)
	{
		tox=x+bmovex[i];
		toy=y+bmovey[i];
		while (tox>0 && toy>0 && tox<9 && toy<9  && map[tox][toy]==' ' )
		{
			sign[tox][toy]=1;
			tox+=bmovex[i];
			toy+=bmovey[i];
		}
	}
	for (i=0;i<4;i++)
	{
		tox=x+rmovex[i];
		toy=y+rmovey[i];
		while (tox>0 && toy>0 && tox<9 && toy<9 && map[tox][toy]==' ' )
		{
			sign[tox][toy]=1;
			tox+=rmovex[i];
			toy+=rmovey[i];
		}
	}
}



main()
{
	char ss[100];
	int i,j,len,a,b,t;

	while (scanf("%s", ss)!=EOF)
	{
		memset(map,0,sizeof(map));
		memset(sign,0,sizeof(sign));
		
		a=1;
		b=1;
		len=strlen(ss);
		for (i=0;i<len;i++)
		{
			if (ss[i]=='/')
			{
				a++;
				b=1;
			}
			else if (ss[i]>='0' && ss[i]<='9')
			{
				t=ss[i]-'0';
				for (j=1;j<=t;j++)
					map[a][b++]=' ';
			}
			else
			{
				map[a][b++]=ss[i];
				
			}
		}
		// check
/*		for (i=1;i<=8;i++)
			printf("%s\n", map[i]+1);
*/
		for (i=1;i<=8;i++)
			for (j=1;j<=8;j++)
			{
				if (map[i][j]==' ') continue;
				else if (map[i][j]=='k' || map[i][j]=='K')	setking(i,j);
				else if (map[i][j]=='r' || map[i][j]=='R')	setr(i,j);
				else if (map[i][j]=='b' || map[i][j]=='B')	setb(i,j);
				else if (map[i][j]=='q' || map[i][j]=='Q')	setq(i,j);
				else if (map[i][j]=='n' || map[i][j]=='N')	setn(i,j);
				else if (map[i][j]=='p') setp(i,j);
				else if (map[i][j]=='P') setp2(i,j);				
			}
		int tot=0;
/*		for (i=1;i<=8;i++)
		{
			for (j=1;j<=8;j++)
				printf("%d", sign[i][j]);
			printf("\n");
		}
		printf("\n");*/
		for (i=1;i<=8;i++)
		{
			for (j=1;j<=8;j++)
			{
				if (sign[i][j]==0 && map[i][j]==' ')
				{
					tot++;
//					printf("*");
				}
//				else 
//					printf("%c", map[i][j]);

			}
//			printf("\n");
		}

		printf("%d\n", tot);
	}

	return 0;
}